System Specification
Autopilot functionalities by functional modules Autopilot Manager Setup, * Active Working mode at start-up is Stand-by. Main loop, * Obtain Current Bearing from Compass. * Obtain Current Rudder position from Linear Actuator. * Target Rudder is evaluated depending on the Active Working Mode. * Linear Actuator will manage the change from Current Rudder to Target Rudder. Working modes Stand-by Target Rudder=Current Rudder. Autopilot is disengaged in Stand-by mode. Auto As PID inputs take, Setpoint (SP) = 0 (Current Bearing(CB) is considered the 0 reference) Process Variable (PV) shall be an angle from -180 to 180. PV = if (Target Bearing-Current Bearing)<=180 then (Error = TB-CB) else (Error = TB-CB-360). Target Rudder = PID (SP, PV) + Autotrim contribution. Nav TBD Wind TBD PID Control The Setpoint (SP) is the value that we want the process to be (i.e. target bearing). The PID controller looks at the setpoint and compares it with the actual value of the Process Variable (PV) (i.e. current bearing). Error is the difference between SP and PV. Error is multiplied by all of the calculated P, I and D Control Actions. Then the resulting Error x Control Actions” are added together and sent to the Controller Output. Controller direction is always direct (i.e. bigger Error shall produce bigger Control Action). PID Gain To configure the PID different parameters are defined, Kp, Ki, Kd are the parameters that drives the P, I and D Control Actions respectivelly. The default are TBC PID method: Proportional On Measurement or Proporcional On Error. Sample Time determines how often the PID algorithm evaluates. The default is 200mS. PID Deadband Deadband goal is to attenuate fluctuations in PID error signal. Using deadband will increase the service life of the actuator. A low pass filter is applied. * Measured value=Previous_Measured value*(1-Deadband_factor) + Measured value(t1)*Deadband_factor Is very useful for D-part of PID to avoid extreme output values for small changes (dx/dt) in signal. AutoTrim AutoTrim = standing helm = speed of learning to apply a new standing helm The AutoTrim setting determines the rate at which the autopilot applies ‘standing helm’ to correct for trim changes caused by varying wind loads on the sails or superstructure. Bearing Rate =speed of change of the bearing angle. When tiller is aligned with the center line of the hull, the bearing rate is 0 deg/sec. When tiller is displaced, the bearing rate increases accordingly. When the tiller displacement is small, the relationship between bearing rate and tiller angle is linear. As shown in the picture, higher displacement of the tiller will cause higher bearing rates. Above a certain tiller displacement (around 45º), the bearing rate stays still and the resistance of the tiller against water is transformed in decreasing boat speed instead of increasing bearing rate. External forces impacting on the boat may cause a torque moment when tiller is aligned. For instance, the wind impacting on sails or hull, outboard installed on a side of the transom. The goal of AutoTrim function is to detect the bearing rate caused by external forces and compensate by displacing the tiller in the oposite direction. AutoTrim function, Consider Y=f(X) were X is the Target Bearing Rate and Y the Requied Tiller Angle. We can aproximate f(X) around X=+-5º to a linear function which verifies Y= A+BX. In perfect conditions, with no wind or tide effect, f(0)=0--> Y=B0*X (Green line in the picture). B0 is the Rudder Gain, a boat constant for a fix speed condition. It can be defined as Installation Parameter. Autotrim function shall be activated for Rudder values <+-5º Autotrim correction shall be evaluated each second and applied proportionally along time (low pass filter) to avoid impacting on PID performance. * If Current Rudder<=5º recalculate trimming. Note that trimming is recalculated only for straight courses, but applied permanently. * Current Change Rate=(Bearing (t1) - Bearing (t0))/(t1-t0). t1-t0=5 seconds. BE CONFIRMED-Period big enough to get valid averages and small enough to avoid PID changes the rudder in the middle * Autotrim = Current Rudder - Rudder Gain*Current Change Rate. * Low pass filter is applied to apply trimming slow enough to avoid impacting PID algorithm. Autotrim = Previous_Autotrim*(1-Autotrim_Gain) + Autotrim * Autotrim_Gain. Installation Parameters Different parameters that are dependant on the autopilot installation or the boat design shall be defined. Centered Tiller Position: Indicates the linear actuator position when the tiller is aligned with the hull. This is the 0º reference for Trimming function. Maximum rudder angle'':' Limit angle of the rudder. It is used to prevent the linear actuator exceeding the rudder angle and damaging the boat. Relative to Centered Tiller Position. Centered Tiller and Maximum Rudder will define the MIN_FEEDBACK and MAX_FEEDBACK parameters of the linear actuator. '''Rudder Gain: is a value that depends on boat design and speed conditions. Different values of Rudder Gain will influence the quantity of rudder correction applied by AutoTrim. TBC: Tests values of Rudder Gain for different boats and speed conditions]. * Rudder Gain=1. to get a turn rate of 1º/sec, it is required 1º of rudder. * Rudder Gain>1. to get a turn rate of 1º/sec, it is required more than 1º or rudder. For slow boats, sailing. * Rudder Gain<1. to get a turn rate of 1º/sec, it is required less than 1º or rudder. For fast boats. Rudder Gain parameter shall be defined at Average Cruise Speed to get the most accurate value. Autotrim_Gain A factor between 0 and 1. Average Cruise Speed: is the nominal speed of the boat. Used by the autopilot in Track mode when speed information is not received from external sources. Installation Side: Side of the boat where the linear actuator is installed. Starboard: Turn to starboard requires extension of the linear actuator from center position. By default. * Linear actuator target position = Controller Output Portboard: Turn to starboard requires retraction of the linear actuator from center position. * Linear actuator target position = - Controller Output Automatic Configuration Autopilot will guide the user in the procedure to obtain the best values for the installation parameters. This excludes compass calibration and permanent deviation parameters. ['TBC] Linear Actuator Rudder Feedback Linear actuator shall provide a Feedback Signal indicating its position. This feedback is an analog signal provided by a potenciometer integrated into the linear actuator. Feedback Parameters Actuator Parameters depends on the specific linear actuator used. The minimum and maximum position is represented by a value of Position Signal between 0 and 1023. Note that minimum may not be represented by 0 and maximum by 1023. * '''''MIN_FEEDBACK: Value of Position Signal in the retracted position (minimum lenght). * MAX_FEEDBACK: Value of Position Signal in the extended position (maximum lenght) To protect linear actuator mechanism from over usage, it is not recomended to arrive to the built-in limits. * LIMIT_FEEDBACK: //Recomended: 1% Position Signal units. To protect linear actuator mechanism from over usage, it is recomended to consider certain error in the Position Signal. * ERROR_FEEDBACK // Recomended: 0,5% Position Signal units. Actuator Controller It requires 2 separate signals to control the motor, one is for direction (counterclockwise or clockwise) and another is for the speed. To control motor direction, DIR pin is connected to HIGH or LOW for different direction, whereas PWM pin is fed with PWM signal to control the motor speed 2 signals are required, * SetDirection: Extend or retract. If previousDirection <> currentDirection then Delay (DELAY_DIRCHANGE) * SetSpeed: Stopped or moving (at highest speed) in the direction established by SetDirection. Actuator Parameters To protect linear actuator from high throughput due to change of direction, it is recomended to add a delay before changing direction. * DELAY_DIRCHANGE: Delay after change of dir in msec. 500 msec recomended. Compass IMU can provide data in different formats. For the purpose of this application, Vector Euler in Degrees is used. IMU_heading = euler.x Permanent Deviation The IMU X axis may not be installed directly pointing to the bow or external magnetics may cause sensor deviations. To correct this, Permanent Deviation parameter can be added to IMU bearing output. Heading = IMU_heading + Permanent_Deviation. Calibration Initial calibration of IMU is required before permanent installation into the boat. BNO055 manufacturer procedure and tools to calibrate and verify are described in the link below. https://www.youtube.com/watch?v=Bw0WuAyGsnY It is very important to follow at least once the calibration, verification and saving procedure described below to get tilt compensated data. After successful calibration, autopilot will save the calibration data into Autopilot EEPROM. This data will be recovered each time the Autopilot is started. However, the calibration, verification and saving process can be performed as many times as required. HMI I/F Functions Switches working mode from STAND BY to AUTO Increment Current Rudder by 1 Position Unit. Set STAND BY Mode. Increment Current Rudder by 10 Position Unit Set STAND BY Mode. Reduce Current Rudder by 1 Position Unit Set STAND BY Mode. Reduce Current Rudder by 10 Position Unit Set STAND BY Mode. Increment Current Rudder by 1 Position Unit Increment Current Rudder by 10 Position Unit Reduce Current Rudder by 1 Position Unit Reduce Current Rudder by 10 Position Unit Set Installation Parameters Change PID gain Change deadband Information from Autopilot: * Current Mode * Current Rudder Position * heading (HDG) * Course To Steer (CTS) - Target Bearing in Auto mode Installation Parameters: * Installation Side * Centered Tiller Position * Maximum rudder angle * Rudder Gain * Autotrim Gain * Average Cruise Speed Functionalities by Hardware components Main Module Main Module provides, * Processing functions are implemented by ARDUINO MEGA 2560 REV3 microcontroller board. * Basic HMI: LCD Keypad and Buzzer * Advanced HMI I/F: Bluetooth * TBC . ARDUINO MEGA 2560 REV3 https://store.arduino.cc/arduino-mega-2560-rev3 LCD Keypad https://www.prometec.net/lcd-keypad-shield/ Bluetooth BT-HC06 https://www.prometec.net/bt-hc06/ Buzzer TBC Motor Controller Linear actuator is driven by a PWM motor controller in Sign-magnitude mode. Main characteristics of Cytron 13A, 5-30V Single DC Motor Controller, * Designed to drive high current brushed DC motor up to 13A continuously * Bi-directional control for 1 brushed DC motor * Support motor voltage ranges from 5V to 30V * Full NMOS H-Bridge for better efficiency and no heat sink is required. Motor Actuator potenciometer Position Signal is an analogic signal from a potenciometer integrated into the linear actuator. IMU MCU+9DOF BNO055 Intelligent 9-axis CJMCU-055 attitude sensor module is used. https://learn.adafruit.com/adafruit-bno055-absolute-orientation-sensor/overview This unit provides tilt compensated heading when properly calibrated and installed without need to perfom complex calculations. Openplotter information Information in ALL working modes from different sources: * Windvane and calculations ** apparent wind angle (AWA) ** apparent wind speed (AWS) ** true wind speed (TWS) ** true wind angle (TWA) * External Compass ** heading (HDG) ** heel angle (HEL) Heeling Angle in degrees of the port/starboard inclination of the boat. * GPS Fix ** Position (Latitude, longitude) ** speed over ground (SOG/SPD) ** course over ground (COG/TRK) * Speed Log ** boat speed trough water (STW) Information in NAV Mode from GPS: * Route ** Previous Waypoint (WPT XXXX) ** Next Waypoint (WPT XXXX) * Angles ** Bearing To next Waypoint (BTW/BRG) ** Turn (TRN) - Difference between TRK and BRG ** Course To Steer (CTS) - An average value between BRG and XTE angle. * Distance ** Distance To next Waypoint (DTW) ** Cross Track Error (XTE) - Minimum distance to route. * Time ** Estimated Time En-route (ETE) ¿Cuanto falta? ** Estimated Time to Arrival (ETA) ¿A qué hora vamos a llegar? * Speed ** Velocity made good (VMG) - Diference in distance to the WP. May be negative